/******************** (C) COPYRIGHT 2014  **************************************
 * chipid.c
 
 * 
*******************************************************************************/
#include "chipid.h"
#include <stdio.h>

/*******************************************************************************
* Function:Get_ChipID
 * A 96 - bit ID is the only identity of stm32, to read 8 bit and 16 bit and 32
bit ,This function provides the big-endian and small-endian of the two methods .
 ********************************************************************/

void Get_ChipID(void)
{
  
    u32 ChipUniqueID[3];
	  //big-endian
	ChipUniqueID[2] = *(__IO u32*)(0X1FFFF7E8);  // 
	ChipUniqueID[1] = *(__IO u32 *)(0X1FFFF7EC); // 	
	ChipUniqueID[0] = *(__IO u32 *)(0X1FFFF7F0); // 

	printf("######## The chip ID is: %08X-%08X-%08X \n\r",\
		ChipUniqueID[0],ChipUniqueID[1],ChipUniqueID[2]); //
		// is the same as ISPMCU serial download  


}

/*********************************************************************

 ********************************************************************/
void Get_Flash_Size(void)
{	
u16 STM32_FLASH_SIZE=*(u16*)(0x1FFFF7E0); //
	printf("######## The chip flash size is: %d Kb \n\r", STM32_FLASH_SIZE);
        printf("######## The code burned date: "__DATE__"  @  "__TIME__"\n\r"); 
        printf("######## The firmware library Vresion: %d.%d.%d \n\r",
			__STM32F10X_STDPERIPH_VERSION_MAIN,
			__STM32F10X_STDPERIPH_VERSION_SUB1,
			__STM32F10X_STDPERIPH_VERSION_SUB2);	 //
   printf("The System Core Clock = %dHz.\n\r",SystemCoreClock);
  
}


 #if 0	//copy the below code to your APP

    /* to get the chipid and put it in ChipUniqueID[3] */
    Get_ChipID();	
    Get_Flash_Size();	

 #endif

/**************END OF FILE************/
